package com.ruoyi.project.business.order.service.impl;


import com.ruoyi.project.business.order.domain.Address;
import com.ruoyi.project.business.order.domain.Order;
import com.ruoyi.project.business.order.mapper.OrderMapper;

import com.ruoyi.project.business.order.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrderServiceImpl implements OrderService
{
    @Autowired
    private OrderMapper orderMapper;

    @Override
    public List<Order> selectOrderList(Order order) {
        List<Order> orders = orderMapper.selectOrderList(order);

        for (Order i : orders) {
            //地址
            Address address = i.getAddress();
            String province = address.getProvince();
            String city = address.getCity();
            String area = address.getArea();
            String detailAddress = address.getDetailAddress();

            province = province + city + area +detailAddress;
            address.setProvince(province);
            i.setAddress(address);


        }

        return orders;
    }

    @Override
    public Order selectOrderById(Integer id) {
        return null;
    }

    @Override
    public int updateOrderStatus(Integer id) {
        // Order order = new Order();
        // order.setId(id);
        // order.setOrderStatus("2");
        // int i = orderMapper.updateById(order);
        orderMapper.updateById(id);

        // System.out.println(i);
        return 1;
    }
}
